package effective.ch03;

/**
 * @description: equals传递性演示
 * @author: Fesine
 * @createTime:2017/1/8 22:00
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/1/8 22:00
 */
public class Point {

    private final int x;
    private final int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    //@Override
    //public boolean equals(Object obj) {
    //    if(!(obj instanceof Point))
    //        return false;
    //    Point p = (Point)obj;
    //    return p.x==x && p.y==y;
    //}

    @Override
    public boolean equals(Object obj) {
        if (obj == null || obj.getClass() != getClass())
            return false;
        Point p = (Point) obj;
        return p.x == x && p.y == y;
    }
}
